#include "ros/ros.h"
#include "turtlesim/Spawn.h"

 
int main(int argc, char *argv[])
{
    setlocale(LC_ALL,"");
    ros::init(argc, argv , "service_call");

    ros::NodeHandle nh;
    ros::ServiceClient client = nh.serviceClient<turtlesim::Spawn>("/spawn");

    turtlesim::Spawn spawn;
    spawn.request.name = "tuttle2";
    spawn.request.x = 1.0;
    spawn.request.y = 4.0;
    spawn.request.theta = 1.57; // 90度

    client.waitForExistence();

    bool flag = client.call(spawn);
    if(flag) 
    {
        ROS_INFO("乌龟%s创建成功", spawn.response.name.c_str());
    }
    else 
    {
        ROS_INFO("乌龟2创建失败");
    }
    ros::spin();

    return 0;
}
